package com.yilin.tms.user.components;

import com.yilin.tms.user.service.IAccountService;
import com.yilin.tms.user.service.IAuthService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceTimerTask {
    Logger logger = LoggerFactory.getLogger(UserServiceTimerTask.class);

    @Resource
    IAuthService authService;

    @Resource
    IAccountService accountService;

    /**
     * 证件认证过期 每日监测任务
     * */
    @Scheduled(cron = "0 0 0 * * ?")
    public void autoCertificatesOverdue(){
        try {
            authService.autoCertificatesOverdue();
        } catch (Exception e) {
            logger.error("证件认证过期任务执行失败！" + e.getMessage());
        }
    }

    /**
     * 账户安全密码隔日恢复服务
     * */
    @Scheduled(cron = "0 0 0 * * ?")
    public void autoSetSafeDisabled(){
        try {
            accountService.autoSetSafeEnable();
        } catch (Exception e) {
            logger.error("账户安全密码隔日恢复服务执行失败！" + e.getMessage());
        }
    }

}
